#include "widget.h"
#include "ui_widget.h"
#include "task.h"

Widget::Widget(QWidget *parent): QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    threadPool.setMaxThreadCount(2);
}
Widget::~Widget()
{  //等待线程池中所有线程结束
    threadPool.waitForDone();
    delete ui;
}
void Widget::on_btnTask_clicked()
{
    for (int i =0 ;i < 10 ;++i ) {
        threadPool.start(new Task(i));
    }
}
